package com.model
{
	public class MenuXMLData
	{
		private static var menubarXML:XML =
			<root>
					<menu label="包围" name="surround" >
							<menuItem id="m1" label="国产">
									<menuItem id="m1_1" label="大包围"/>
									<menuItem id="m1_2" label="小包围"/>
							</menuItem>
							<menuItem id="m2" label="台湾">
									<menuItem id="m2_1" label="大包围"/>
									<menuItem id="m2_2" label="小包围"/>
							</menuItem>
							<menuItem id="m3" label="德国">
									<menuItem id="m3_1" label="大包围"/>
									<menuItem id="m3_2" label="小包围"/>
							</menuItem>
					</menu>
					<menu label="尾翼" name="empennage" >
							<menuItem id="m1" label="国产">
									<menuItem id="m1_1" label="大尾翼"/>
									<menuItem id="m1_2" label="小尾翼"/>
							</menuItem>
							<menuItem id="m2" label="台湾">
									<menuItem id="m2_1" label="大尾翼"/>
									<menuItem id="m2_2" label="小尾翼"/>
							</menuItem>
							<menuItem id="m3" label="德国">
									<menuItem id="m3_1" label="大尾翼"/>
									<menuItem id="m3_2" label="小尾翼"/>
							</menuItem>
					</menu>
					<menu label="轮毂" name="wheelHub" >
							<menuItem id="m1" label="国产">
									<menuItem id="m1_1" label="大轮毂"/>
									<menuItem id="m1_2" label="小轮毂"/>
							</menuItem>
							<menuItem id="m2" label="台湾">
									<menuItem id="m2_1" label="大轮毂"/>
									<menuItem id="m2_2" label="小轮毂"/>
							</menuItem>
							<menuItem id="m3" label="德国">
									<menuItem id="m3_1" label="大轮毂"/>
									<menuItem id="m3_2" label="小轮毂"/>
							</menuItem>
					</menu>
					<menu label="排气" name="exhaust">
							<menuItem id="m1" label="国产">
									<menuItem id="m1_1" label="大排气"/>
									<menuItem id="m1_2" label="小排气"/>
							</menuItem>
							<menuItem id="m2" label="台湾">
									<menuItem id="m2_1" label="大排气"/>
									<menuItem id="m2_2" label="小排气"/>
							</menuItem>
							<menuItem id="m3" label="德国">
									<menuItem id="m3_1" label="大排气"/>
									<menuItem id="m3_2" label="小排气"/>
							</menuItem>
					</menu>
					<menu label="发动机盖" name="frontklappe">
							<menuItem id="m1" label="国产">
									<menuItem id="m1_1" label="大机盖"/>
									<menuItem id="m1_2" label="小机盖"/>
							</menuItem>
							<menuItem id="m2" label="台湾">
									<menuItem id="m2_1" label="大机盖"/>
									<menuItem id="m2_2" label="小机盖"/>
							</menuItem>
							<menuItem id="m3" label="德国">
									<menuItem id="m3_1" label="大机盖"/>
									<menuItem id="m3_2" label="小机盖"/>
							</menuItem>
					</menu>
					<menu label="贴纸" name="paster">
							<menuItem id="m1" label="国产">
									<menuItem id="m1_1" label="大贴纸"/>
									<menuItem id="m1_2" label="小贴纸"/>
							</menuItem>
							<menuItem id="m2" label="台湾">
									<menuItem id="m2_1" label="大贴纸"/>
									<menuItem id="m2_2" label="小贴纸"/>
							</menuItem>
							<menuItem id="m3" label="德国">
									<menuItem id="m3_1" label="大贴纸"/>
									<menuItem id="m3_2" label="小贴纸"/>
							</menuItem>
					</menu>
			</root>;
		
		public static function getSubFirstItem(sid:int):XML{
			return getMenuList(sid)[0].menuItem[0];
		}
		
		/**
		 * 获取父容器的
		 */		
		public static function getParentItem(index:int,itemId:String):XML{
			var itemList:XMLList = getMenuList(index);
			var pId:String = itemId.split('_')[0];
			for each (var menuItem:XML in itemList) 
			{
				if(pId == menuItem.@id){
					return menuItem;
				}
			}
			return null;
		}
		/**
		 * 获取对应索引值的xmllist列表
		 * @return XMLList
		 */		
		public static function getMenuList(index:int):XMLList{
			return menubarXML.menu[index].menuItem;
		}
		/**
		 * 获取标题列表的功能
		 */		
		public static function getMenuTitle(onTitle:Function):void{
			var menuList:XMLList = menubarXML.menu;
			for (var i:int = 0; i < menuList.length(); i++) 
			{
				onTitle(i,menuList[i].@label,menuList[i].@name);
			}
		}
		/*public static function getMenuName():Vector.<String>{
			var menuList:XMLList = menubarXML.menu;
			var mList:Vector.<String> = new Vector.<String>();
			for each (var menuItem:XML in itemList){
				
			}
			return mList;
		}*/
		
		public static function get menuLength():int{
			return menubarXML.menu.length();
		}
		
		public static function getItemIDList(index:int):Vector.<String>{
			var idList:Vector.<String> = new Vector.<String>();
			var itemList:XMLList = getMenuList(index);
			for each (var menuItem:XML in itemList) 
			{
				for each (var childItem:XML in menuItem.menuItem) 
				{
					idList.push(childItem.@id);
				}
			}
			return idList;
		}
		
		
	}
}